package src.ee.ioc.smaug.ui.evolver;


import java.io.File;
import java.io.IOException;
import java.net.URL;


import javax.swing.JEditorPane;
import javax.swing.JOptionPane;

import src.ee.ioc.smaug.ui.WMain;


public class POpenFilePanel  {
    public static JEditorPane showPanel(File openFile){
        
        if(!openFile.exists()) {        
                JOptionPane.showMessageDialog(WMain.DMain, 
                        openFile.getName()+ " file does not exist", "File error",
                        JOptionPane.ERROR_MESSAGE); 
                return null;
            }
        
    JEditorPane openPanel = new JEditorPane();

    openPanel.setEditable(false);
    URL resURL=null;
    
    try {
    resURL =new URL  ("file:/"+ openFile.getAbsolutePath());
    } catch (IOException e) {
        
    }
    
    if (resURL != null) {
        try {
            openPanel.setPage(resURL);
        } catch (IOException e) {
            System.err.println("Attempted to read a bad URL" );
        }
    } else {
        System.err.println("Couldn't find file "+openFile.getName());
    }
    return openPanel;
    }
}
